package com.dlc.yunguang.net.protocol;

import android.support.annotation.Nullable;

import com.dlc.yunguang.model.InventoryRecordBean;
import com.dlc.yunguang.net.bean.MoveProductBean;
import com.dlc.yunguang.net.bean.ProductBean;
import com.dlc.yunguang.net.bean.RFIDBean;
import com.dlc.yunguang.net.bean.StockNumberBean;
import com.dlc.yunguang.net.bean.WareFrameBean;
import com.dlc.yunguang.net.bean.WarehouseBean;
import com.dlc.yunguang.net.protocol.base.HttpProtocol;
import com.lzy.okgo.model.HttpParams;

import rx.Observable;

/**
 * 货物盘点
 */
public class CountingProto extends HttpProtocol {

    private CountingProto() {
    }

    private static class InstanceHolder {
        private static final CountingProto sProtocol = new CountingProto();
    }

    public static CountingProto get() {
        return InstanceHolder.sProtocol;
    }


    /**
     * 获取库存单号
     * @param error
     * @return
     */
    public Observable<StockNumberBean> getStockNumber(@Nullable String error) {
        return rxPost("stock_main", null,StockNumberBean.class,true, error);
    }

    /**
     * 获取仓库列表
     * @param error
     * @return
     */
    public Observable<WarehouseBean> getWarehouseList(@Nullable String error) {
        return rxPost("warehouse", null,WarehouseBean.class,true, error);
    }

    /**
     * 获取货架列表
     * @param pid
     * @return
     */
    public Observable<WareFrameBean> getWareFrameList(String pid) {
        HttpParams params = new HttpParams();
        params.put("warehouse_id",pid);
        return rxPost("ware_frame", params,WareFrameBean.class,true,null);
    }

    /**
     * 获取货架上规格数量(盘点)
     * @param warehouseId wareFrameId
     * @return
     */
    public Observable<ProductBean> getWareFrameSpec(String warehouseId, String wareFrameId) {
        HttpParams params = new HttpParams();
        params.put("warehouse_id",warehouseId);//只要传这个参数就可以了
       // params.put("ware_frame_id",wareFrameId);
        return rxPost("ware_frame_spec", params,ProductBean.class,true,null);
    }

    /**
     * 获取货架上规格数量（移库）
     * @param warehouseId wareFrameId
     * @return
     */
    public Observable<MoveProductBean> getWareFrameSpecMove(String warehouseId, String wareFrameId) {
        HttpParams params = new HttpParams();
        params.put("warehouse_id",warehouseId);
        params.put("ware_frame_id",wareFrameId);
        return rxPost("ware_frame_spec", params,MoveProductBean.class,true,null);
    }

    /**
     * 获取rfid列表
     * @param params
     * @return
     */
    public Observable<RFIDBean> getInventory(HttpParams params) {
        return rxPost("rfid", params,RFIDBean.class,true,null);
    }

    /**
     * 盘点纪录
     * @param params
     * @return
     */
    public Observable<InventoryRecordBean> stockRecord(HttpParams params) {
        return rxPost("stock_record", params,InventoryRecordBean.class,true,null);
    }

    /**
     * 盘点提交
     * @param params
     * @return
     */
    public Observable<Object> stock(HttpParams params) {
        return rxPost("stock", params,Object.class,true,null);
    }
}
